Skip to content

handle heterogeneous arrays in flattening pass - #660

Draft
tim-hoffman wants to merge 121 commits into
mainfrom
th/296
Draft

handle heterogeneous arrays in flattening pass#660
tim-hoffman wants to merge 121 commits into
mainfrom
th/296

Conversation

@tim-hoffman

Copy link
Copy Markdown
Member

Summary

Update flattening pass to create a series of flattened structs for an array of heterogeneous structs.

Related issues

Fixes #296

@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74c9383a7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

  2 files  ± 0    2 suites  ±0   6m 48s ⏱️ +30s
427 tests +31  423 ✅ +31  4 💤 ±0  0 ❌ ±0 
854 runs  +62  846 ✅ +62  8 💤 ±0  0 ❌ ±0 

Results for commit 123bafa. ± Comparison against base commit 683c6d4.

♻️ This comment has been updated with latest results.

Base automatically changed from th/applymap_folding to main July 31, 2026 00:40
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf4ba11ae4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44d8aafd08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0414c2294

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Block &newTemplateBody = newTemplate.getBodyRegion().front();
for (Attribute name : layout.remainingNames) {
FlatSymbolRefAttr nameSym = llvm::cast<FlatSymbolRefAttr>(name);
Operation *paramOp = symTables.getSymbolTable(parentTemplate).lookup(nameSym.getAttr());
assert(paramOp && "symbol must exist");
newTemplateBody.push_back(paramOp->clone());

P1 Badge Preserve sibling callees in partial templates

When the partially instantiated function contains a flat call to a sibling function in the original template, the cloned template contains only the remaining parameters, copied expressions, and newFunc; it does not contain that sibling. The flat callee consequently resolves relative to the new template and becomes an unknown symbol, so applyBodyConversions() rejects an otherwise valid partial instantiation. Copy referenced sibling functions recursively or rewrite such callees to a path that still resolves in the original template.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 755ef86fa9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

ArrayType newType = createResultType.cloneWith(newResultElemType);
rewriter.modifyOpInPlace(op, [&createResult, &newType]() { createResult.setType(newType); });

P1 Badge Validate array users before refining initializer-driven types

When a member-read refinement changes every array.new initializer to a concrete type, this mutation updates the array SSA value globally without checking consumers of that array. A generic array can initially be passed to a call expecting array<Cell<1>>, while its generic initializer is later refined to Cell<0> by another member write; this branch changes the argument to array<Cell<0>>, and no propagation pattern updates the callee parameter, leaving the call invalid. Check the array value's typed consumers before committing the initializer-driven element refinement.


replaceOpWithNewOp<ExtractArrayOp>(
rewriter, op, newResultTy, adaptor.getArrRef(), adaptor.getIndices()
);

P2 Badge Preserve attributes when converting wildcard array reads

When function instantiation resolves a wildcard scalar element to an array, this replacement creates an ExtractArrayOp without copying the original ReadArrayOp's discardable attributes. An annotated read therefore loses metadata such as product_source specifically along the new scalar-to-ranged conversion path; transfer the source read's discardable attribute dictionary to the replacement.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

include/llzk/Dialect/Polymorphic/Transforms/TransformationPasses.td:62

  • This documentation names poly.const_read, but the registered operation is poly.read_const (include/llzk/Dialect/Polymorphic/IR/Ops.td:236). Use the actual operation spelling so users can find and invoke it.
    - Replace instantiated `poly.const_read` uses, symbolic member table

test/Transforms/Flattening/test/Transforms/Flattening/member_read_array_initializer_reproducer.llzk:1

  • This test was added under a duplicated test/Transforms/Flattening directory hierarchy, unlike the other flattening tests. Move it to test/Transforms/Flattening/member_read_array_initializer_reproducer.llzk so the suite layout and reported test path remain consistent.

Comment on lines +2758 to +2760
}
}
return success();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llzk-flatten generates invalid code on circom example 2B

2 participants